package com.aiiter.web.controller.house;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.aiiter.house.domain.vo.HousePendingTaskVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aiiter.common.annotation.Log;
import com.aiiter.common.core.controller.BaseController;
import com.aiiter.common.core.domain.AjaxResult;
import com.aiiter.common.enums.BusinessType;
import com.aiiter.house.domain.HousePendingTask;
import com.aiiter.house.service.IHousePendingTaskService;
import com.aiiter.common.utils.poi.ExcelUtil;
import com.aiiter.common.core.page.TableDataInfo;

/**
 * 待办任务Controller
 * 
 * @author ruoyi
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/house/pendingTask")
public class HousePendingTaskController extends BaseController
{
    @Autowired
    private IHousePendingTaskService pendingTaskService;

    /**
     * 查询待办任务列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HousePendingTask task)
    {
        startPage();
        List<HousePendingTaskVo> list = pendingTaskService.selectHousePendingTaskList(task);
        return getDataTable(list);
    }

    /**
     * 导出待办任务列表
     */
    @Log(title = "待办任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HousePendingTask task)
    {
        List<HousePendingTaskVo> list = pendingTaskService.selectHousePendingTaskList(task);
        ExcelUtil<HousePendingTaskVo> util = new ExcelUtil<HousePendingTaskVo>(HousePendingTaskVo.class);
        util.exportExcel(response, list, "待办任务数据");
    }

    /**
     * 获取待办任务详细信息
     */
    @GetMapping(value = "/{pendingId}")
    public AjaxResult getInfo(@PathVariable("pendingId") Long pendingId)
    {
        return success(pendingTaskService.selectHousePendingTaskByPendingId(pendingId));
    }

    /**
     * 新增待办任务
     */
    @Log(title = "待办任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HousePendingTask task)
    {
        return toAjax(pendingTaskService.insertHousePendingTask(task));
    }

    /**
     * 修改待办任务
     */
    @Log(title = "待办任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HousePendingTask task)
    {
        return toAjax(pendingTaskService.updateHousePendingTask(task));
    }

    /**
     * 删除待办任务
     */
    @Log(title = "待办任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pendingIds}")
    public AjaxResult remove(@PathVariable Long[] pendingIds)
    {
        return toAjax(pendingTaskService.deleteHousePendingTaskByPendingIds(pendingIds));
    }
}
